
#pragma once
#include <math.h>
#include <limits>

#define EPSILON 0.00001f
const float fuzzyEpsilon = 0.00001f;

inline float DegToRad(float x)
{
	return x * 0.01745329251994329547f;	// PI / 180
}
inline float RadToDeg(float x)
{
	return x * 57.2957795130823228646f;	// 1.0 / (PI / 180)
}
inline const float& inf() {

	// float is a standard type and should have infinity
	static const float i = std::numeric_limits<float>::infinity();
	return i;
}
inline const float& pi() {
	static const float p = 3.1415926f;
	return p;
}

/** Returns a reference to a static haft. */
inline const float& halfPi() {
	static const float p = pi() / 2.0f;
	return p;
}

/** Returns a reference to a static float. */
inline const float& twoPi() {
	static const float p = pi() * 2.0f;
	return p;
}
inline float MathAbs (float fValue) {
	return float(fabs(fValue));
}
inline float eps(float a, float b) {
	
	(void)b;
	const float aa = abs(a) + 1;
	if (aa == inf()) {
		return fuzzyEpsilon;
	} else {
		return fuzzyEpsilon * aa;
	}
}

inline bool fuzzyEq(float a, float b) {
	return (a == b) || (MathAbs(a - b) <= eps(a, b));
}

inline bool fuzzyNe(float a, float b) {
	return ! fuzzyEq(a, b);
}

inline bool fuzzyGt(float a, float b) {
	return a > b + eps(a, b);
}

inline bool fuzzyGe(float a, float b) {
	return a > b - eps(a, b);
}

inline bool fuzzyLt(float a, float b) {
	return a < b - eps(a, b);
}

inline bool fuzzyLe(float a, float b) {
	return a < b + eps(a, b);
}